Implement correct :disabled support for fieldsets and nested form controls#125
Implement correct :disabled support for fieldsets and nested form controls#125dperini merged 3 commits intodperini:masterfrom
:disabled support for fieldsets and nested form controls#125Conversation
| // F is true if any of the fieldset elements in the ancestry chain has the disabled attribute specified | ||
| // L is true if the first legend element of the fieldset contains the element | ||
| 'var x=0,N=[],F=false,L=false;' + | ||
| 'if(!(/^(optgroup|option)$/i.test(e.localName))){' + |
There was a problem hiding this comment.
This feels a bit messy, but optgroup has different definitions for disabled, as the HTML spec notes in the disabled attribute documentation:
The disabled attribute for option elements and the disabled attribute for optgroup elements are defined separately.
We shouldn't take into account fieldset/legend for optgroup/option, so we skip over code related to that here.
|
@camchenry |
|
@dperini Thanks, let me know if there is anything I can do to help with this PR. I did test it out in Chrome 127 on macOS and it looked okay, but I didn't try any other browsers so far. |
|
@camchenry |
|
@camchenry & @kmcgrady |
<fieldset>considered:disabledif it contains<legend>jsdom/jsdom#3232With the current implementation of the
:disabledselector, there are two main issues:legend. Currently, the check for if the legend element contains the element doesn't handle if the first legend element doesn't exist in the fieldset. Specifically,(n=s.ancestor("fieldset",e))&&(n=s.first("legend",n))&&!n.contains(e))returns false becausen=s.first("legend",n)evaluates tonullwhich is falsey, so the whole AND expression evaluates to false. Rather, if there is no legend element, we do not need to consider if the element is contained within the legend element and can solely focus on whether it is disabled or a descendant of a disabled fieldset.Since the original
test/w3c/html/semantics/selectors/pseudo-classes/disabled.htmlweb-platform-test was added, it has been updated with additional test-cases. So I have added those here to ensure this works correctly.